VERSION 5.00
Begin VB.Form frmsubreport2 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Select month"
   ClientHeight    =   3045
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4455
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3045
   ScaleWidth      =   4455
   Begin VB.CommandButton Command1 
      Caption         =   "Run report"
      Height          =   495
      Left            =   3000
      TabIndex        =   6
      Top             =   2400
      Width           =   1095
   End
   Begin VB.CheckBox chkAdvanceDate 
      Caption         =   "Expenditure report for more than one month"
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   120
      TabIndex        =   7
      Top             =   0
      Width           =   3855
   End
   Begin VB.Frame Frame2 
      Height          =   1815
      Left            =   120
      TabIndex        =   17
      Top             =   360
      Visible         =   0   'False
      Width           =   3975
      Begin VB.ComboBox cboFM 
         Enabled         =   0   'False
         Height          =   315
         Left            =   1200
         TabIndex        =   0
         Text            =   "01"
         Top             =   240
         Width           =   855
      End
      Begin VB.ComboBox cboFY 
         Enabled         =   0   'False
         Height          =   315
         Left            =   2640
         TabIndex        =   1
         Top             =   240
         Width           =   1095
      End
      Begin VB.ComboBox cboTM 
         Enabled         =   0   'False
         Height          =   315
         Left            =   1200
         TabIndex        =   2
         Text            =   "01"
         Top             =   600
         Width           =   855
      End
      Begin VB.ComboBox cboTY 
         Enabled         =   0   'False
         Height          =   315
         Left            =   2640
         TabIndex        =   3
         Top             =   600
         Width           =   1095
      End
      Begin VB.ComboBox cboFinancial 
         Enabled         =   0   'False
         Height          =   315
         Left            =   1200
         TabIndex        =   4
         Text            =   "ALL"
         Top             =   960
         Width           =   2535
      End
      Begin VB.ComboBox cboOffice2 
         Enabled         =   0   'False
         Height          =   315
         Left            =   1200
         TabIndex        =   5
         Text            =   "SGN"
         Top             =   1320
         Width           =   1335
      End
      Begin VB.Label Label4 
         Alignment       =   1  'Right Justify
         Caption         =   "From Month"
         Height          =   255
         Left            =   120
         TabIndex        =   23
         Top             =   240
         Width           =   975
      End
      Begin VB.Label Label5 
         Alignment       =   1  'Right Justify
         Caption         =   "Year"
         Height          =   255
         Left            =   1920
         TabIndex        =   22
         Top             =   240
         Width           =   615
      End
      Begin VB.Label Label6 
         Alignment       =   1  'Right Justify
         Caption         =   "To Month"
         Height          =   255
         Left            =   120
         TabIndex        =   21
         Top             =   600
         Width           =   975
      End
      Begin VB.Label Label7 
         Alignment       =   1  'Right Justify
         Caption         =   "Year"
         Height          =   255
         Left            =   2160
         TabIndex        =   20
         Top             =   600
         Width           =   375
      End
      Begin VB.Label Label8 
         Alignment       =   1  'Right Justify
         Caption         =   "Financial"
         Height          =   255
         Left            =   240
         TabIndex        =   19
         Top             =   960
         Width           =   855
      End
      Begin VB.Label Label9 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Office"
         Height          =   195
         Left            =   675
         TabIndex        =   18
         Top             =   1320
         Width           =   420
      End
   End
   Begin VB.Frame Frame1 
      Height          =   1815
      Left            =   120
      TabIndex        =   10
      Top             =   360
      Width           =   3975
      Begin VB.ComboBox cboOffice 
         Height          =   315
         Left            =   675
         TabIndex        =   13
         Top             =   240
         Width           =   2055
      End
      Begin VB.ComboBox cboMonth 
         Height          =   315
         Left            =   675
         TabIndex        =   12
         Top             =   600
         Width           =   615
      End
      Begin VB.ComboBox cboYear 
         Height          =   315
         Left            =   1755
         TabIndex        =   11
         Top             =   600
         Width           =   975
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Office"
         Height          =   195
         Left            =   150
         TabIndex        =   16
         Top             =   240
         Width           =   420
      End
      Begin VB.Label Label2 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Month"
         Height          =   195
         Left            =   120
         TabIndex        =   15
         Top             =   600
         Width           =   450
      End
      Begin VB.Label Label3 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         Caption         =   "Year"
         Height          =   195
         Left            =   1320
         TabIndex        =   14
         Top             =   600
         Width           =   330
      End
   End
   Begin VB.CommandButton Command4 
      Caption         =   "EXPENDITURE BY OFFICE"
      Height          =   375
      Left            =   5400
      TabIndex        =   9
      Top             =   840
      Width           =   2655
   End
   Begin VB.CommandButton Command7 
      Caption         =   "EXPENDITURE FOR GINDO"
      Height          =   495
      Left            =   5400
      TabIndex        =   8
      Top             =   1320
      Width           =   2655
   End
End
Attribute VB_Name = "frmsubreport2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
 

Private Sub cboFinancial_GotFocus()
    tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFM_Click()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFM_LostFocus()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFY_Click()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboFY_LostFocus()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboTM_Click()
    If Val(cboTY.Text) = Val(cboFY.Text) Then
        If Val(cboTM.Text) < Val(cboFM.Text) Then
            MsgBox "The TO MONTH must be greater then FROM MONTH", vbCritical + vbOKOnly, "Checking"
            Exit Sub
        End If
    End If
End Sub

 

Private Sub cboTM_LostFocus()
    'tem = SetFinancial(cboFM, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2))
End Sub

Private Sub cboTY_Click()
    If Val(cboTY.Text) < Val(cboFY.Text) Then
        MsgBox "The TO YEAR must be greater then FROM YEAR", vbCritical + vbOKOnly, "Checking"
    End If
End Sub

Private Sub chkAdvanceDate_KeyUp(KeyCode As Integer, Shift As Integer)
    If chkAdvanceDate.Value = 0 Then
        cboFM.Enabled = True
        cboTM.Enabled = True
        cboFY.Enabled = True
        cboTY.Enabled = True
        cboOffice2.Enabled = True
        cboOffice.Enabled = False
        cboFinancial.Enabled = True
        cboOffice.Enabled = False
        Frame1.Visible = False
        Frame2.Visible = True
        
        If Command1.Tag = "GER" Or Command1.Tag = "GCF" Then
            cboOffice2.Enabled = False
            cboOffice.Enabled = False
        Else
            cboOffice2.Enabled = True
            cboOffice.Enabled = True
        End If
        
    Else
        cboFM.Enabled = False
        cboTM.Enabled = False
        cboFY.Enabled = False
        cboTY.Enabled = False
        cboOffice2.Enabled = False
        cboFinancial.Enabled = False
        cboOffice.Enabled = True
        
        cboOffice.Enabled = False
        Frame1.Visible = True
        Frame2.Visible = False
        
        If Command1.Tag = "GER" Or Command1.Tag = "GCF" Then
            cboOffice2.Enabled = False
            cboOffice.Enabled = False
        Else
            cboOffice2.Enabled = True
            cboOffice.Enabled = True
        End If
    End If
End Sub

Private Sub chkAdvanceDate_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
    If chkAdvanceDate.Value = 1 Then
        cboFM.Enabled = True
        cboTM.Enabled = True
        cboFY.Enabled = True
        cboTY.Enabled = True
        cboOffice2.Enabled = True
        cboFinancial.Enabled = True
        cboOffice.Enabled = False
    
        Frame1.Visible = False
        Frame2.Visible = True
        
        If Command1.Tag = "GER" Or Command1.Tag = "GCF" Then
            cboOffice2.Enabled = False
            cboOffice.Enabled = False
        Else
            cboOffice2.Enabled = True
            cboOffice.Enabled = True
        End If
    Else
        cboFM.Enabled = False
        cboTM.Enabled = False
        cboFY.Enabled = False
        cboTY.Enabled = False
        cboOffice2.Enabled = False
        cboFinancial.Enabled = False
        cboOffice.Enabled = True
        Frame1.Visible = True
        Frame2.Visible = False
        
        If Command1.Tag = "GER" Or Command1.Tag = "GCF" Then
            cboOffice2.Enabled = False
            cboOffice.Enabled = False
        Else
            cboOffice2.Enabled = True
            cboOffice.Enabled = True
        End If
    End If
End Sub

Private Sub cmdGindo_Click()
    'On Error Resume Next
    Dim previousMMYY As String
    Dim mm, yy As String
    mm = cboMonth.Text
    yy = Right(cboYear.Text, 2)
    
    If Val(mm) = 1 Then
        previousMMYY = "120" & Val(yy) - 1
    ElseIf Val(mm) - 1 < 10 Then
        previousMMYY = "0" & Val(mm) - 1 & yy
    ElseIf Val(mm) - 1 >= 10 Then
        previousMMYY = Val(mm) - 1 & yy
    End If
    
    DetectExcel
    If Not isExistBalance(Left(previousMMYY, 2), Right(previousMMYY, 2), Right(cboOffice.Text, 3)) Then
        If MsgBox("The balance of previous month does not exist. Do you want to update the balance manually?(Y/N)", vbQuestion + vbYesNo + vbDefaultButton2, "Update Balance?") = vbNo Then
            Exit Sub
        Else
            frmBalance.Show
            frmBalance.cboBMonth.Text = Left(previousMMYY, 2)
            frmBalance.cboBYear.Text = "20" & Right(previousMMYY, 2)
            Exit Sub
        End If
    End If
    
    Call funCASHFLOWREPORT(cboMonth.Text, Right(cboYear.Text, 2), 1)
End Sub

Private Sub Command1_Click()
    Me.Hide
    If Trim(cboFinancial.Text) = "" And chkAdvanceDate.Value = 1 Then
        MsgBox "You must be select financial year.", vbCritical + vbOKOnly, "Accounting"
        Exit Sub
    End If
    
    Select Case Command1.Tag
        Case "ER"
            'Chay bao cao cho tung khu vuc
            Call Command4_Click
        Case "GER"
            'Chay bao cao cho ca GINDO
            Call Command7_Click
        Case Else
            MsgBox "Unkow"
    End Select
    Unload Me
End Sub

Private Sub Command3_Click()
    'On Error Resume Next
    Dim previousMMYY As String
    Dim mm, yy As String
    
    mm = cboMonth.Text
    yy = Right(cboYear.Text, 2)
    
    If Val(mm) = 1 Then
        previousMMYY = "120" & Val(yy) - 1
    ElseIf Val(mm) - 1 < 10 Then
        previousMMYY = "0" & Val(mm) - 1 & yy
    ElseIf Val(mm) - 1 >= 10 Then
        previousMMYY = Val(mm) - 1 & yy
    End If
    
    DetectExcel
    If Not isExistBalance(Left(previousMMYY, 2), Right(previousMMYY, 2), Right(cboOffice.Text, 3)) Then
        If MsgBox("The balance of previous month does not exist. Do you want to update the balance manually?(Y/N)", vbQuestion + vbYesNo + vbDefaultButton2, "Update Balance?") = vbNo Then
            Exit Sub
        Else
            frmBalance.Show
            frmBalance.cboBMonth.Text = Left(previousMMYY, 2)
            frmBalance.cboBYear.Text = "20" & Right(previousMMYY, 2)
            Exit Sub
        End If
    End If
    
    TotalExpenditureInCashFlow = 0
    Call funCASHFLOWREPORT(cboMonth.Text, Right(cboYear.Text, 2), 0)
End Sub

Private Sub Command4_Click()
    'On Error Resume Next
     
    Dim ExcelWasNotRunning As Boolean   ' Flag for final release.
    Dim previousYear As String
    previousYear = Val(Right(cboYear.Text, 2)) - 1
    
    If Len(previousYear) < 2 Then
        previousYear = "0" & previousYear
    End If
    TotalExpenditureCheck = 0
    isExportExpenditureForGindo = False
    isNoCloseExcel = False
    
    DetectExcel
    If chkAdvanceDate.Value = 1 Then
        'If Val(cboTM.Text) < Val(cboFM.Text) Then
             'MsgBox "The TO MONTH must be greater then FROM MONTH", vbCritical + vbOKOnly, "Checking"
            ' Exit Sub
        'End If
        isFillCheck = 1
        isCreateNewExcel = True
        Call funExpenditureREPORT(cboFinancial.Text, "", cboFM.Text, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2), cboOffice2.Text, False, True)
    
    Else
        Select Case Val(cboMonth.Text)
        
        Case 1, 2, 3
            isFillCheck = 1
            isCreateNewExcel = True
            'Call funExpenditureREPORT(previousYear & "S", cboMonth.Text, Right(cboYear.Text, 2), cboOffice.Text)
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "F", previousYear & "S", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, False, False)
        Case 4, 5, 6
            isFillCheck = 2
            isCreateNewExcel = True
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "F", "", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, False, False)
        Case 7, 8, 9
            isFillCheck = 1
            isCreateNewExcel = True
            'Call funExpenditureREPORT(Right(cboYear.Text, 2) & "F", cboMonth.Text, Right(cboYear.Text, 2), cboOffice.Text)
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "S", Right(cboYear.Text, 2) & "F", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, False, False)
        Case 10, 11, 12
            isFillCheck = 2
            isCreateNewExcel = True
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "S", "", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, False, False)
        End Select
    End If
End Sub

Private Sub Command7_Click()
    'NQMinh: Chay bao cao cho GINDO
    'On Error Resume Next
    Dim previousYear As String
    previousYear = Val(Right(cboYear.Text, 2)) - 1
    If Len(previousYear) < 2 Then
        previousYear = "0" & previousYear
    End If
    DetectExcel
    
    TotalExpenditureCheck = 0
    isExportExpenditureForGindo = True
    
    If chkAdvanceDate.Value = 1 Then
        'NQMINH: Chay theo khoang thoi gian da chon
        isFillCheck = 1
        isCreateNewExcel = True
        Dim financial As String
        financial = cboFinancial.Text
        'If (financial = "All") Then
         'Call funExpenditureREPORT("ALL", "", cboFM.Text, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2), cboOffice2.Text, True, True)
         'Call funExpenditureREPORT(CStr(previousYear) & "F", "", cboFM.Text, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2), cboOffice2.Text, True, True)
         'Call funExpenditureREPORT(CStr(previousYear) & "S", "", cboFM.Text, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2), cboOffice2.Text, True, True)
        'Else
            Call funExpenditureREPORT(financial, "", cboFM.Text, Right(cboFY.Text, 2), cboTM.Text, Right(cboTY.Text, 2), cboOffice2.Text, True, True)
        'End If
         
        'Call funExpenditureREPORT(Right(cboFY.Text, 2) & "S", Right(cboFY.Text, 2) & "F", cboFM.Text, Right(cboFY.Text, 2), cboTM.Text, Right(cboFY.Text, 2), cboOffice.Text, True, True)
    
    Else
        'NQMINH: chay theo thang
        Select Case Val(cboMonth.Text)
        
        Case 1, 2, 3
            isFillCheck = 1
            isCreateNewExcel = True
            'Call funExpenditureREPORT(previousYear & "S", cboMonth.Text, Right(cboYear.Text, 2), cboOffice.Text)
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "F", previousYear & "S", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, True, False)
        Case 4, 5, 6
            isFillCheck = 2
            isCreateNewExcel = True
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "F", "", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, True, False)
        Case 7, 8, 9
            isFillCheck = 1
            isCreateNewExcel = True
            'Call funExpenditureREPORT(Right(cboYear.Text, 2) & "F", cboMonth.Text, Right(cboYear.Text, 2), cboOffice.Text)
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "S", Right(cboYear.Text, 2) & "F", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, True, False)
        Case 10, 11, 12
            isFillCheck = 2
            isCreateNewExcel = True
            Call funExpenditureREPORT(Right(cboYear.Text, 2) & "S", "", cboMonth.Text, Right(cboYear.Text, 2), "", "", cboOffice.Text, True, False)
        End Select
    End If
End Sub

Private Sub Form_Load()
    DetectExcel
    Me.Top = Screen.Height / 2 - (Me.Height / 1.5)
        Me.Left = Screen.Width / 2 - (Me.Width / 2)
    Call KetNoi
    '
    'For i = 1 To 9
    '    cboMonth.AddItem "0" & i
    'Next i
    'For i = 10 To 12
    '    cboMonth.AddItem i
    'Next i
    'If Month(Now()) < 10 Then
    '    If Month(Now()) = 1 Then
    '        cboMonth.Text = "0" & Month(Now())
    '    Else
    '        cboMonth.Text = "0" & Month(Now()) - 1
    '    End If
    'Else
    '    cboMonth.Text = Month(Now()) - 1
    'End If
    'For i = 7 To Val(Right(Year(Now()), 2))
    '    cboYear.AddItem "200" & i
    'Next i
    'cboYear.Text = Year(Now())
    
    'Select Case permit
    '    Case "A", "B", "G"
    '        cboOffice.Enabled = True
    ''        cboOffice.AddItem "GHAN"
    ''        cboOffice.AddItem "GSGN"
    ''        'cboOffice.AddItem "GDAD"
    ''        cboOffice.AddItem "GPNH"
    ''        cboOffice.AddItem "GVTE"
    ''        cboOffice.ListIndex = 1
    '    Case Else
    '        cboOffice.AddItem "G" & stroffice
    '        cboOffice.ListIndex = 0
    '        cboOffice.Enabled = False
    'End Select
    '
    
    DetectExcel
    Me.Top = Screen.Height / 2 - (Me.Height / 1.5)
        Me.Left = Screen.Width / 2 - (Me.Width / 2)
    Call KetNoi
    
    For I = 1 To 9
        cboMonth.AddItem "0" & I
    Next I
    
    For I = 10 To 12
        cboMonth.AddItem I
    Next I
    
    If Month(Now()) < 10 Then
        If Month(Now()) = 1 Then
            cboMonth.Text = "0" & Month(Now())
        Else
            cboMonth.Text = "0" & Month(Now()) - 1
        End If
    ElseIf Month(Now()) = 10 Then
        cboMonth.Text = "0" & Month(Now()) - 1
    Else
        cboMonth.Text = Month(Now()) - 1
    End If
    
    For I = 7 To Val(Right(Year(Now()), 2))
        '''''''''cboYear.AddItem "200" & i
        If I < 10 Then
            cboYear.AddItem "20" & I
        Else
            cboYear.AddItem "20" & I
        End If
    Next I
    
    If Month(Now()) = 1 Then
        cboYear.Text = Year(Now()) - 1
    Else
        cboYear.Text = Year(Now())
    End If
    
    
    
    ''''''''cboYear.Text = Year(Now())
    
    For I = 1 To 9
        cboFM.AddItem "0" & I
        cboTM.AddItem "0" & I
        If Val(I) = Month(Now()) Then
            cboFM.ListIndex = I - 1
            cboTM.ListIndex = I - 1
        End If
    Next
    
    For I = 10 To 12
        cboFM.AddItem I
        cboTM.AddItem I
    Next
    
    For I = 2008 To Year(Now()) + 1
        cboFY.AddItem I
        cboTY.AddItem I
    Next
    
    cboFY.Text = Year(Now())
    cboTY.Text = Year(Now())
    
    Select Case permit
        Case "A", "B", "G"
            cboOffice.Enabled = True
            'cboOffice2.Enabled = True
            chkAdvanceDate.Enabled = True
            
            cboOffice.AddItem "GHAN"
            cboOffice.AddItem "GSGN"
            'cboOffice.AddItem "GDAD"
            cboOffice.AddItem "GPNH"
            cboOffice.AddItem "GVTE"
            cboOffice.ListIndex = 1
            
            'cmdGindo.Enabled = True
            
            cboOffice2.AddItem "GHAN"
            cboOffice2.AddItem "GSGN"
            'cboOffice2.AddItem "GDAD"
            cboOffice2.AddItem "GPNH"
            cboOffice2.AddItem "GVTE"
            cboOffice2.ListIndex = 1
    
        Case Else
    
            cboOffice.AddItem "G" & stroffice
            cboOffice.Text = "G" & stroffice
            cboOffice2.AddItem "G" & stroffice
            cboOffice2.Text = "G" & stroffice
            cboOffice.ListIndex = 0
            cboOffice.Enabled = False
            cboOffice2.Enabled = False
            'chkAdvanceDate.Enabled = False
            chkAdvanceDate.Enabled = True
                
    End Select
End Sub

Private Function SetFinancial(fromMonth As Integer, fromYear As Integer, toMonth As Integer, toYear As Integer) As String
    Dim I As Integer
    cboFinancial.Clear
    
    If fromYear > toYear Then
        SetFinancial = "'From year' can not be greater then 'to year'"
        Exit Function
    ElseIf fromYear = toYear Then
        If fromMonth > toMonth Then
            SetFinancial = "'From month' can not be greater then 'to month'"
            Exit Function
        End If
    End If
    
    cboFinancial.AddItem "ALL"
    
    If fromMonth >= 1 And fromMonth <= 3 Then
        If fromYear - 1 < 10 Then
            cboFinancial.AddItem "0" & fromYear - 1 & "S"
        Else
            cboFinancial.AddItem fromYear - 1 & "S"
        End If
    End If
    
    For I = fromYear To toYear Step 1
        If I < 10 Then
            cboFinancial.AddItem "0" & I & "F"
            cboFinancial.AddItem "0" & I & "S"
            cboFinancial.AddItem "0" & I & "A"
        Else
            cboFinancial.AddItem I & "F"
            cboFinancial.AddItem I & "S"
            cboFinancial.AddItem I & "A"
        End If
    Next I
    
    cboFinancial.Text = "ALL"
    SetFinancial = ""
End Function

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    On Error Resume Next
    ApExcel.Quit
End Sub

Private Sub Form_Terminate()
    On Error Resume Next
    ApExcel.Quit
End Sub

Private Sub Form_Unload(Cancel As Integer)
    On Error Resume Next
    ApExcel.Quit
End Sub
